(load "schemer.ss")

(define (eternity x) (display "--- eternity ---") (newline) 0)

(define length
  (lambda (l)
    (if (null? l)
      0
      (add1 (length (cdr l))))))

(define A
  ((lambda (length)
     (lambda (l)
       (cond
         ((null? l) 0)
         (else (+ 1 (length (cdr l)))))))
   ((lambda (length)
      (lambda (l)
        (cond
          ((null? l) 0)
          (else (+ 1 (length (cdr l)))))))
    eternity))
)

(define B

((lambda (mk-length)
   (mk-length mk-length))
 (lambda (length)
   (lambda (l)
     (if (null? l)
       0
       (add1 ((length length) (cdr l)))))))
)

(define C

  ((lambda (mk-length)
     (mk-length mk-length))
   (lambda (mk-length)
     ((lambda (length)
        (lambda (l)
          (if (null? l)
            0
            (add1 (length (cdr l))))))
      (lambda (x)
        ((mk-length mk-length) x)))))
)

